HOW TO ENABLE WIFI AP AND STA
1. OVERVIEW¶
sta mode: take wifi as a client to connect AP/router.
ap mode: take wifi as a hotspot for other devices to connect.
2. CODE MODIFICATION AND CONFIGURATION¶
-
Config first, then compile.
-
Enabled wifi by default.
-
Enable zk_full mode: vim project/release/customer_tailor/nvr_i2m_display_glibc_tailor.mk verify_zk_full:=enable
-
Delete the last line of code in
sdk\verify\application\zk_full\demo.sh
to avoid conflicts when the UI calls wifi......... cd /customer chmod 777 zkgui #./zkgui &
-
Compile to update, and then restart.
-
3. 修改板端行为¶
-
Add information of AP
/ # vi appconfigs/wpa_supplicant.conf ctrl_interface=/tmp/wifi/run/wpa_supplicant update_config=1 network={ ssid="aryl iPhone" psk="123456789a" }
-
Initialize wifi
cd /config/wifi export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/lib:/config/wifi ./ssw01bInit.sh
-
Test wifi connection(connect and get the IP, then view it through a router or cell phone)
./wpa_supplicant -Dnl80211 -i wlan0 -c /appconfigs/wpa_supplicant.conf -d & sleep 2 udhcpc -q -i wlan0 -s /etc/init.d/udhcpc.script &
-
Scan hotspot
./iwlist wlan0 scanning
-
Check the connection status
./wpa_cli -i wlan0 -p /tmp/wifi/run/wpa_supplicant status
-
ping
ping -I wlan0 14.215.177.39
-
DNS mount -o remount,rw / If dns sever is a invalid ip, change it to 8.8.8.
-
Edit vi /etc/resolv.conf
export LD_LIBRARY_PATH=$LD_LIBRARY_ifPATH:/customer/libdns ping -I wlan0 www.baidu.com
STA mode finished verification when completed the test steps above.
-
Enable AP mode
ifconfig p2p0 up ifconfig p2p0 192.168.1.100 netmask 255.255.255.0 ./hostapd -B /config/wifi/hostapd.conf ./dnsmasq -i p2p0 --no-daemon -C /config/wifi/dnsmasq.conf &
Check the device information:
./hostapd_cli -i p2p0 -p /var/run/hostapd all_sta &
-
Search ssid by PC: ssw101bap; passwd:12345678(ssid and password can be changed in hostapd.conf)
AP mode finished verification when completed the test steps above.
STA and AP modes finished verification when completed the test steps above.